export default {
  data() {
    return {
      searchItem: {
        searchKey: "",
      },
      showModal: false,
      styles: {
        height: "calc(100% - 55px)",
        overflow: "auto",
        paddingBottom: "53px",
        position: "static",
      },

      columns: [
        {
          title: "图片",
          key: "faceurl",
          slot:"faceurl"
        },
        {
          title: "姓名",
          key: "name",
        },
        {
          title: "工号",
          key: "uid",
          align: "center",
        },

        {
          title: "操作",
          key: "action",
          align: "center",
          width: 150,
          slot: "action",
          fixed: "right",
        },
      ],
      count: 0,
      total: 0,
      page: 1,
      pageSize: 10,
      datalist: [],
      showImport: false,
    };
  },
  computed: {
    user() {
      return this.$store.state.user;
    },
  },
  methods: {
    pageChange(page) {
      this.page = page;
      this.getData();
    },
    pageSizeChange(pageSize) {
      this.pageSize = pageSize;
      this.getData();
    },
    getData() {
      this.$axios({
        url: `/face/list`,
        method: "POST",
        data: {
          page: this.page,
          pageSize: this.pageSize,
          searchKey: this.searchItem.searchKey,
        },
      }).then((res) => {
        if (res.code == 200) {
          this.datalist = res.data.list;
          this.total = res.data.total;
        }
      });
    },
    deleteInfo(index) {
      var that = this;
      var model = this.datalist[index];
      this.$Modal.confirm({
        title: "删除提示",
        content: `确定要删除：“${model.name}” 人脸信息么？`,
        onOk: () => {
          this.$axios({
            url: `/face/${model.uid}`,
            method: "DELETE",
          }).then((res) => {
            if (res.code == 200) {
              this.$Message.info(res.data);
              that.getData();
            } else {
              this.$Message.error(res.msg);
            }
          });
        },
      });
    },
  },
  created() {
    this.getData();
  },
};
